home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Classic 39
/
CD CLASSIC #39 (1998).iso
/
EMPRESA
/
visio
/
Vistdstd
/
Install
/
Data.Z
/
Network.FRM
< prev
next >
Wrap
Text File
|
1996-09-03
|
5KB
|
160 lines
VERSION 4.00
Begin VB.Form Network
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Network Diagram Example"
ClientHeight = 2280
ClientLeft = 1095
ClientTop = 1485
ClientWidth = 7365
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 2685
Left = 1035
LinkTopic = "Form1"
ScaleHeight = 2280
ScaleWidth = 7365
Top = 1140
Width = 7485
Begin VB.Label Label1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "The Form_Load procedure of this form creates a Visio network diagram from a database."
ForeColor = &H80000008&
Height = 855
Left = 1560
TabIndex = 0
Top = 480
Width = 4215
End
End
Attribute VB_Name = "Network"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
' -----------------------------------------------------------------------------
' Copyright (C) 1996 Visio Corporation. All rights reserved.
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Visio has no warranty,
' obligations or liability for any Sample Application Files.
' -----------------------------------------------------------------------------
Option Explicit
Private Sub Form_Load()
' This example demonstrates generating a Visio drawing from the data contained
' in a database.
' Declare database variables
Dim NetBase As DAO.Database
Dim NetInfo As DAO.Recordset
' Declare Visio variables
Dim Visio As Visio.Application
Dim NetDiagram As Visio.Page
Dim NetStencil As Visio.Document
Dim Master As Visio.Master
Dim Shape As Visio.Shape
Dim TextShape As Visio.Shape
Dim Ethernet As Visio.Shape
Dim ControlCell As Visio.Cell
Dim ConnectCell As Visio.Cell
Dim Chars As Visio.Characters
' Declare miscellaneous variables
Dim Digit As Integer
Dim NodeType As String
Dim Label As String
Dim Index As Integer
Dim XPos As Double
' Open the database and get the NetInfo table
Set NetBase = OpenDatabase(App.Path & "\network.mdb", True, True)
Set NetInfo = NetBase.OpenRecordset("NetInfo")
' Get a Visio Object that is already running.
On Error Resume Next
Set Visio = GetObject(, "Visio.Application")
If Err Then
MsgBox "Launch Visio First"
End
End If
On Error GoTo 0
' Open the NetDB template and retrieve the stencil
Set NetDiagram = Visio.Documents.Add("VB Solutions.vst").Pages(1)
Set NetStencil = Visio.Documents("VB Solutions.vss")
' Set the size of the Page. We have to access cells in the special
' shape "thePage" where page attributes are stored.
NetDiagram.Shapes("thePage").Cells("PageWidth").Formula = 8
NetDiagram.Shapes("thePage").Cells("PageHeight").Formula = 2.5
' Drop the Ethernet master onto the page.
Set Master = NetStencil.Masters("EtherNet")
Set Ethernet = NetDiagram.Drop(Master, 1, 1)
' Extend the Shape to fill up the whole page.
Ethernet.SetBegin 0.5, 2
Ethernet.SetEnd 7.5, 2
' Loop over each record in the database.
NetInfo.MoveFirst
XPos = 1
Digit = Asc("1")
While Not NetInfo.EOF
Visio.ScreenUpdating = False
' Drop a node symbol on the page for this database record.
NodeType = NetInfo.Fields("Node")
Set Master = NetStencil.Masters(NodeType)
Set Shape = NetDiagram.Drop(Master, XPos, 0.875)
XPos = XPos + 1.5
' Add a label to each node symbol in the diagram.
Label = NetInfo.Fields("Name")
Label = Label & Chr$(13) & Chr$(10)
Label = Label & NetInfo.Fields("Dept")
Shape.Text = Label
' Fill in the Data1 Field in each shape from the database spec field.
' This information is available in the FormatSpecial dialog.
Shape.Data1 = NetInfo.Fields("Spec")
' Connect the network lines to the computers. The EtherNet shape has
' control handles that can be glued to the connection points on the
' computer shapes. The top connection point on each node is
' always the 5'th one.
Set ControlCell = Ethernet.Cells("Controls.X" & Chr$(Digit))
Digit = Digit + 1
Set ConnectCell = Shape.Cells("Connections.X5")
ControlCell.GlueTo ConnectCell
' Embolden the first line of the text on each shape. Since this shape
' is a group, dive down and get the shape that the text is really on.
Index = Shape.Shapes.Count
Set TextShape = Shape.Shapes(Index)
Set Chars = TextShape.Characters
Chars.End = InStr(TextShape.Text, Chr$(13)) - 1
Chars.CharProps(visCharacterStyle) = visBold
Visio.ScreenUpdating = True
NetInfo.MoveNext
Wend
NetInfo.Close
NetBase.Close
End
End Sub